# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Evan Teitelman <teitelmanevan at gmail dot com>
# Contributor: fxbru <frxbru[at]gmail>

pkgname=sqlmap
pkgver=1.7
pkgrel=2
pkgdesc='Automatic SQL injection and database takeover tool'
url='https://sqlmap.org'
arch=('any')
license=('GPL2')
depends=('python' 'sh')
optdepends=('perl: icmpsh extra tool')
backup=('etc/sqlmap.conf')
source=(https://github.com/sqlmapproject/sqlmap/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('ca79239eec7b0e72a37de65471787800837b01c9567a8dae617bda5f4dde70c80a0d2e8f38373245bf43cf6feaca19e606dddd482f7c1ca7b18745ca107693f3')
b2sums=('5a30cb111b0b6b8c37ff8b9ec37e3724b51b9a41cdd3d75d9665cfc6ceb4c9d11d642714cd327669015309b427184663c0ba248c4158378489bc5e0668a8cb7a')

build() {
  cd ${pkgname}-${pkgver}
  python -m compileall .
  python -O -m compileall .
}

package() {
  cd ${pkgname}-${pkgver}

  install -d "${pkgdir}/etc"
  install -d "${pkgdir}/usr/bin"
  install -d "${pkgdir}/opt/${pkgname}"
  install -d "${pkgdir}/usr/share/doc"

  mv doc "${pkgdir}/usr/share/doc/${pkgname}"
  mv sqlmap.conf "${pkgdir}/etc/sqlmap.conf"
  ln -sf /etc/sqlmap.conf "${pkgdir}/opt/${pkgname}/sqlmap.conf"
  cp -a --no-preserve=ownership * "${pkgdir}/opt/${pkgname}"

  cat > "${pkgdir}/usr/bin/sqlmap" << EOF
#!/bin/sh
cd /opt/${pkgname}
python sqlmap.py "\$@"
EOF
  cat > "${pkgdir}/usr/bin/sqlmapapi" << EOF
#!/bin/sh
cd /opt/${pkgname}
python sqlmapapi.py "\$@"
EOF

  chmod 755 "${pkgdir}/usr/bin/sqlmap"
  chmod 755 "${pkgdir}/usr/bin/sqlmapapi"
}

# vim: ts=2 sw=2 et:
